dojo.provide('details');
dojo.require('dijit._Widget');
dojo.require('dijit._Templated');

dojo.declare('widgets.mobile.details.details', [dijit._Widget, dijit._Templated], {
	
	templatePath : new dojo._Url('dojo-release-1.7.1/dojo/widgets/mobile/details/', 'details.html'),
	
	imagePath : "", //"dojo-release-1.7.2/widgets/mobile/details/default.jpg",
	items : null,
	shadow: false,
	
	addImage : function(){
		
		if(this.imagePath != ""){
			var imageContainer = this._imageContainer;
			dojo.addClass(imageContainer, "imageContainer");
			var image = this._image;
			dojo.addClass(image, "image");
		}
	},
	
	addItems : function(){
		
		if(this.items != null){
			
			var content = this._content;
			
			for(var i=0; i<this.items.length; i++){
				var itemContainer = dojo.create("div", {});
				if(i != (this.items.length-1) ){
					dojo.addClass(itemContainer, "item");
				}
				var left = dojo.create("div", {innerHTML: this.items[i].leftLabel, class: "leftLabel"});
				var right = dojo.create("div", {innerHTML: this.items[i].rightLabel, class: "rightLabel"});
				itemContainer.appendChild(right);
				itemContainer.appendChild(left);
				content.appendChild(itemContainer);
			}
		}
	},
	
	addShadow : function(){
		
		if(this.shadow){
			var container = this._container;
			dojo.setStyle(container, "box-shadow", "5px 5px 5px #777777");
		}
	},
	
	addCSStoPage: function(){
		
		var headID = document.getElementsByTagName("head")[0];         
		var cssNode = document.createElement('link');
		cssNode.type = 'text/css';
		cssNode.rel = 'stylesheet';
		cssNode.href = 'dojo-release-1.7.1/dojo/widgets/mobile/details/details.css';
		cssNode.media = 'screen';
		headID.appendChild(cssNode);
		
	},
	
	postCreate : function(){
		this.addCSStoPage();
		this.addImage();		
		this.addItems();
		this.addShadow();
	},
		
});